package function;

import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

@FunctionHint(output = @DataTypeHint("Row<source string,ct bigint>"))
public class kwProductUDTF extends TableFunction<Row> {
    public void eval(Long clickCt, Long orderCt, Long cartCt) {
        if (clickCt > 0) {
            collect(Row.of("click", clickCt));
        }
        if (orderCt > 0) {
            collect(Row.of("order", orderCt));
        }
        if (cartCt > 0) {
            collect(Row.of("cart", cartCt));

        }
    }

}
